<?php
class Admin_UsersController extends Zend_Controller_Action
{


   public function init(){
       $css = new App_Model_Pulpit();
       $this->view->css = $css->pulpitcss();
       
       $this->adduser_form=new Admin_Form_User;
   }
   
   public function indexAction(){
    
    
   }
   
   public function adduserAction(){
    $this->view->adduser=$this->adduser_form;
    
    if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($this->adduser_form->isValid($formData)){
                $imie=$this->adduser_form->getValue('imie');
                $nazwisko=$this->adduser_form->getValue('nazwisko');
                $login=$this->adduser_form->getValue('login');
                $haslo=$this->adduser_form->getValue('haslo');
                $email=$this->adduser_form->getValue('mail');
                $gg=$this->adduser_form->getValue('gadugadu');
                $telefon=$this->adduser_form->getValue('telefon');
                $adres=$this->adduser_form->getValue('adres');
                               
                $user=new Admin_Model_Uzytkownik();
                if($user->sprawdzlogin($login)==0&&$user->sprawdzmail($email)==0){
                $user->dodajUzytkownika($imie,$nazwisko,$login,$haslo,$email,$gg,$telefon,$adres);
                }
                $this->_helper->redirector('index','index');
                
             } else {
                 $this->form->populate($formData);
             }
         }
    
   }
   
   public function userlistAction(){
        
        $aszerzy = new Admin_Model_Uzytkownik();
        $this->view->efekt=$aszerzy->daj_liste();
        
    
   }
   
   public function userlistbannedAction(){
        
        $aszerzy = new Admin_Model_Uzytkownik();
        $this->view->efekt=$aszerzy->daj_liste_banned();
        
    
   }
   
    public function userlistblockedAction(){
        
        $aszerzy = new Admin_Model_Uzytkownik();
        $this->view->efekt=$aszerzy->daj_liste_blocked();
        
    
   }
   
    public function banujAction()
    {
        
        $login=$this->_getParam('login', 0);
        $aszerzy = new Admin_Model_Uzytkownik();
        $aszerzy->banuj($login);
        $this->_helper->redirector('userlist','users');
             
        
    }
    
    public function odbanujAction()
    {
        
        $login=$this->_getParam('login', 0);
        $aszerzy = new Admin_Model_Uzytkownik();
        $aszerzy->odbanuj($login);
        $this->_helper->redirector('userlist','users');
             
        
    }
   
   public function userlogsAction(){
    
    
   }
}

